<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>

<div class="t_bar">
	<span class="color_red">*</span>${param.title }
</div>
<table id="eq_table1" cellpadding="0" class="t_css" width="100%" border="0" cellpadding="0" style="*border-bottom: #a1c0dc 1px solid;">
	<thead>
		<tr style="border: 1px solid #B7D1E6">
			<th class="TblHead" align="center" width="10%">选择</th>
			<th class="TblHead" align="center" width="10%">序号</th>
			<th class="TblHead" align="center" width="26%">投保险种</th>
			<th class="TblHead" align="center" width="27%">保费（万元）</th>
			<th class="TblHead" align="center" width="27%">保额（万元）</th>
		</tr>
	</thead>
	<tbody id="tab">
		<tr style="display: none">
			<td align="center"><input type="radio" name="selMileStones" style="border:0px;background-color:white"></td>
			<td align="center"><span name="proposal|toubao_list[0]@seq_no">[index]</span></td>
			<td align="center"><input type="text" name="proposal|toubao_list[0]|type" class="hn_iuput_kuang1 required maxlength:50" style="width: 80%" label="投保险种" value="" maxlength="50" /></td>
			<td align="center"><input type="text" name="proposal|toubao_list[0]|cost" class="hn_iuput_kuang1 required maxlength:50" onfocus="InitInput.setNumber(this,9,2,2);"style="width: 80%;text-align: right;" label="保费（万元）" onchange="autoCalFund('eq_table1','cost','total_baofei')" value="" maxlength="50" /></td>
			<td align="center"><input type="text" name="proposal|toubao_list[0]|money"  class="hn_iuput_kuang1 required maxlength:50 " onfocus="InitInput.setNumber(this,9,2,2);"style="width: 80%; text-align: right;" label="保额（万元）" onchange="autoCalFund('eq_table1','money','total_baoe')" value="" maxlength="50" /></td>
		</tr>
        <c:set value="0" var="index" scope="page" />
		<x:forEach select="$xmlData/data/proposal/toubao_list" var="toubao_list">
			<c:choose>
				 <c:when test="${index<10}" ><c:set value="0" var="flag" scope="page"/></c:when>
				<c:otherwise><c:set value="" var="flag" scope="page"/></c:otherwise>
			</c:choose>
			<tr>
				<td align="center"><input type="radio" class="radiobutton" name="selMileStones" style="border:0px;background-color:white"></td>
				<td align="center"><span name="proposal/toubao_list[${flag}${index}]@seq_no"><x:out select="$toubao_list/@seq_no" /></span></td>
				<td align="center"><input type="text" name="proposal/toubao_list[${flag}${index}]/type" value="<x:out select="$toubao_list/type" />" class="hn_iuput_kuang required maxlength:50" style="width: 80%" label="投保险种 " onchange="" maxlength="50" /></td>
				<td align="center"><input type="text" name="proposal/toubao_list[${flag}${index}]/cost" value="<x:out select="$toubao_list/cost"/>" class="hn_iuput_kuang1 required maxlength:50" onfocus="InitInput.setNumber(this,9,2,2);"style="width: 80%;text-align: right;" label="保费（万元）" onchange="autoCalFund('eq_table1','cost','total_baofei')" maxlength="50" /></td>
				<td align="center"><input type="text" name="proposal/toubao_list[${flag}${index}]/money"value="<x:out select="$toubao_list/money"/>" class="hn_iuput_kuang1 required maxlength:50" onfocus="InitInput.setNumber(this,9,2,2);" style="width: 80%; text-align: right;" label="保额（万元）" onchange="autoCalFund('eq_table1','money','total_baoe')" maxlength="50" /></td>
			</tr>
			<c:set value="${index+1}" var="index" scope="page" />
			<!-- <script type="text/javascript">
						showAllDateTag("eq_table1");
			</script> -->
		</x:forEach>
	</tbody>
</table>

<table cellpadding="0" class="table01 t_css" width="100%" border="0"
		cellpadding="0" style="*border-bottom: #a1c0dc 1px solid;">
		<col style="width: 46%" />
		<col style="width: 27%" />
		<col style="width: 27%" />
		<tr>
			<td align="center">合计（万元）</td>
			<td align="center"><input type="text" name="proposal/total_baofei" id="total_baofei" value="<x:out select="$xmlData/data/proposal/total_baofei"/>" class="hn_iuput_kuang1 required maxlength:50 gray" onfocus="InitInput.setNumber(this,9,2,2);" onchange="" style="width: 80%; text-align: right;" disabled maxlength="50" /></td>
			<td align="center"><input type="text" name="proposal/total_baoe"  id ="total_baoe" value="<x:out select="$xmlData/data/proposal/total_baoe"/>" class="hn_iuput_kuang1 required maxlength:50 gray" onfocus="InitInput.setNumber(this,9,2,2);" onchange="" style="width: 80%; text-align: right;" disabled maxlength="50" /></td>
		</tr>
</table>

<table width="98%" align="center">
	<tr>
		<td><input class="button_02" name="cmdAddbefore"type=button value="添加" onclick="if(checkTabLimit('eq_table1',999,'投保情况最多只能填写999条')){addNewRow('eq_table1');showDateTag('eq_table1');}try{top.resizeFrame();}catch(e){};">
			<input class="button_02" name="cmdMovePrev" type=button value="上移" onclick="movePrev('eq_table1','selMileStones');"> 
			<input class="button_02" name="cmdMoveNext" type=button value="下移" onclick="moveNext('eq_table1','selMileStones');">
		    <input class="button_02" name="cmddel" type=button value="删除" onclick="deleteSelectedRow('eq_table1','投保情况');autoCalFund('eq_table1','money','total_baoe');autoCalFund('eq_table1','cost','total_baofei');">
		</td>
	</tr>
</table>
<script type="text/javascript">
	
	function count() {
		$("#eq_table1 tr:gt(1)").each(function() {
			var price_each=$(this).find("td:eq(4) input").val();
			var num=$(this).find("td:eq(5) input").val();
			$(this).find("td:eq(6) input").val(formatVal(price_each*num));
		});
		$("#eq_table2 tr:gt(1)").each(function() {
			var price_each=$(this).find("td:eq(4) input").val();
			var num=$(this).find("td:eq(5) input").val();
			$(this).find("td:eq(6) input").val(formatVal(price_each*num));
		});
	}
	function formatVal(count) {
		if (!$.isNumeric(count))
		count = "0";
		count = ((parseFloat(count) * 10000) / 10000).toFixed(4);
		count = formatNumberAuto(count.toString(), 9, 4, 2);// 格式化金额
		return count;
	}
	function checkTab2() {
		if($("#eq_table2 tr").length>2){
	    	$("#eq_tab2_val").val("1");
	    }else{
	    	$("#eq_tab2_val").val("");
	    }
	}	
	 function autoCalFund(tabid,endName,targetId){
		 var num=0.00 ;
		 $("#"+tabid).find("tr td input[name$="+endName + " ]").each(function(){
			if( $(this).val() =='' ||$(this).val() ==undefined )	{
				return  ; 
			}
			num =num*10000 +parseFloat($(this).val())*10000  ;
			num =num/10000 ;
		 });
		 $("#"+targetId).val(formatNumberAutoOther(num.toString(), 9, 4, 2));    
	 }
</script>
